#include <iostream>
using namespace std;
int main()
{
    int t = 0;
    cin >> t;
    while(t--)
    {
        int h = 0, a = 0, H = 0, A = 0;
        cin >> h >> a >> H >> A; // 血量攻击力 血量攻击力
        int res = 0;
        int tmp = H;
        while(h > 0)
        {
            // cout << h << " " << a << " " << tmp << " " << A << " res " << res << endl;
            if(A <= 0 || H <= a)
            {
                res = -1;
                break;
            }
            if(a <= 0)
            {
                res = 0;
                break;
            }
            tmp -= a;
            if(tmp <= 0)
            {
                ++res;
                tmp = H;
                continue;
            }
            h -= A;
        }
        cout << res << endl;
    }
    return 0;
}